package eventReservationServer.saxParser;

import java.util.Collection;

import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;

public class XMLServices
{	
	public static Collection<Service> getServices()
	{
		SAXParserFactory factory = SAXParserFactory.newInstance();
		factory.setValidating(true);
		try
		{
			System.out.println("ANALISIS DE UN DOCUMENTO XML USANDO SAX");
			System.out.println("-------- -- -- --------- --- ------ ---");
			SAXParser saxParser = factory.newSAXParser();
			EventServerGatewaysSAXHandler handler = new EventServerGatewaysSAXHandler();
			saxParser.parse("EventReservationCore/src/eventReservationServer/saxParser/services.xml", handler); // ruta relativa directamente al fichero xml

			System.out.println(handler.getServices());
			
			return handler.getServices();
		}
		catch (Exception e)
		{
			System.out.println("Error -> Main():" + e.getMessage());
			e.printStackTrace();
			return null;
		}
	}
}
